package cn.sdormitory.controller;

import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.service.AppReportService;
import cn.sdormitory.smartdor.vo.SdAttenceAppVo;
import cn.sdormitory.smartdor.vo.SdAttenceReportVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author: lx
 * @date: 2023/11/7 10:24
 * @description:
 */
@RestController
@RequestMapping("/app/report")
@Api("APP端报表接口")
public class AppReportController {

    @Autowired
    AppReportService appReportService;

    @ApiOperation(value = "出勤比例 => 获取宿舍出勤率根据楼栋楼层")
    @PostMapping("/getSdAttendanceRateByBuildStorey")
    public CommonResult getSdAttendanceRateByBuildStorey(@RequestBody Map<String, String> param){
        String date = param.get("date");
        List<Map<String, Object>> data = appReportService.getSdAttendanceRateByBuildStorey(date);
        return CommonResult.success(data);
    }

    @ApiOperation(value = "考勤统计 => 获取宿舍出勤学生人数据楼栋楼层,按类型分类")
    @PostMapping("/getSdAttenceStuCountByBuildStorey")
    public CommonResult getSdAttenceStuCountByBuildStorey(@RequestBody Map<String, String> param){
        String date = param.get("date");
        List<Map<String, Object>> data = appReportService.getSdAttenceStuCountByBuildStorey(date);
        return CommonResult.success(data);
    }

    @ApiOperation(value = "出勤异常统计")
    @PostMapping("/getStuExcAttence")
    public CommonResult getStuExcAttence(@RequestBody Map<String, String> param){
        String startDate = param.get("startDate");
        String endDate = param.get("endDate");
        String attenceStauts = param.get("attenceStauts");
        String buildingNo = param.get("buildingNo");
        List<SdAttenceReportVo> data = appReportService.getStuExcAttence(startDate,endDate,attenceStauts,buildingNo);
        return CommonResult.success(data);
    }
}
